home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / Portable Patmos / usr / include / sys / wait.h < prev   
Encoding:
C/C++ Source or Header  |  1994-11-08  |  5.5 KB  |  166 lines  |  [TEXT/R*ch]

  1. /*
  2.  * Copyright (c) 1982, 1986, 1989 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *    This product includes software developed by the University of
  16.  *    California, Berkeley and its contributors.
  17.  * 4. Neither the name of the University nor the names of its contributors
  18.  *    may be used to endorse or promote products derived from this software
  19.  *    without specific prior written permission.
  20.  *
  21.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.  * SUCH DAMAGE.
  32.  *
  33.  *    from: @(#)wait.h    7.17 (Berkeley) 6/19/91
  34.  *    $Id: wait.h,v 1.4 1993/10/11 18:18:10 jtc Exp $
  35.  */
  36.  
  37. #ifndef _SYS_WAIT_H_
  38. #define _SYS_WAIT_H_
  39.  
  40. /*
  41.  * This file holds definitions relevent to the wait4 system call
  42.  * and the alternate interfaces that use it (wait, wait3, waitpid).
  43.  */
  44.  
  45. /*
  46.  * Macros to test the exit status returned by wait
  47.  * and extract the relevant values.
  48.  */
  49. #ifdef _POSIX_SOURCE
  50. #define    _W_INT(i)    (i)
  51. #else
  52. #define    _W_INT(w)    (*(int *)&(w))    /* convert union wait to int */
  53. #define    WCOREFLAG    0200
  54. #endif
  55.  
  56. #define    _WSTATUS(x)    (_W_INT(x) & 0177)
  57. #define    _WSTOPPED    0177        /* _WSTATUS if process is stopped */
  58. #define WIFSTOPPED(x)    (_WSTATUS(x) == _WSTOPPED)
  59. #define WSTOPSIG(x)    (_W_INT(x) >> 8)
  60. #define WIFSIGNALED(x)    (_WSTATUS(x) != _WSTOPPED && _WSTATUS(x) != 0)
  61. #define WTERMSIG(x)    (_WSTATUS(x))
  62. #define WIFEXITED(x)    (_WSTATUS(x) == 0)
  63. #define WEXITSTATUS(x)    (_W_INT(x) >> 8)
  64. #ifndef _POSIX_SOURCE
  65. #define WCOREDUMP(x)    (_W_INT(x) & WCOREFLAG)
  66.  
  67. #define    W_EXITCODE(ret, sig)    ((ret) << 8 | (sig))
  68. #define    W_STOPCODE(sig)        ((sig) << 8 | _WSTOPPED)
  69. #endif
  70.  
  71. /*
  72.  * Option bits for the second argument of wait4.  WNOHANG causes the
  73.  * wait to not hang if there are no stopped or terminated processes, rather
  74.  * returning an error indication in this case (pid==0).  WUNTRACED
  75.  * indicates that the caller should receive status about untraced children
  76.  * which stop due to signals.  If children are stopped and a wait without
  77.  * this option is done, it is as though they were still running... nothing
  78.  * about them is returned.
  79.  */
  80. #define WNOHANG        1    /* dont hang in wait */
  81. #define WUNTRACED    2    /* tell about stopped, untraced children */
  82.  
  83. #ifndef _POSIX_SOURCE
  84. /* POSIX extensions and 4.2/4.3 compatability: */
  85.  
  86. /*
  87.  * Tokens for special values of the "pid" parameter to wait4.
  88.  */
  89. #define    WAIT_ANY    (-1)    /* any process */
  90. #define    WAIT_MYPGRP    0    /* any process in my process group */
  91.  
  92. #ifndef BYTE_ORDER
  93. #include <machine/endian.h>
  94. #endif
  95.  
  96. /*
  97.  * Deprecated:
  98.  * Structure of the information in the status word returned by wait4.
  99.  * If w_stopval==WSTOPPED, then the second structure describes
  100.  * the information returned, else the first.
  101.  */
  102. union wait {
  103.     int    w_status;        /* used in syscall */
  104.     /*
  105.      * Terminated process status.
  106.      */
  107.     struct {
  108. #if BYTE_ORDER == LITTLE_ENDIAN 
  109.         unsigned int    w_Termsig:7,    /* termination signal */
  110.                 w_Coredump:1,    /* core dump indicator */
  111.                 w_Retcode:8,    /* exit code if w_termsig==0 */
  112.                 w_Filler:16;    /* upper bits filler */
  113. #endif
  114. #if BYTE_ORDER == BIG_ENDIAN 
  115.         unsigned int    w_Filler:16,    /* upper bits filler */
  116.                 w_Retcode:8,    /* exit code if w_termsig==0 */
  117.                 w_Coredump:1,    /* core dump indicator */
  118.                 w_Termsig:7;    /* termination signal */
  119. #endif
  120.     } w_T;
  121.     /*
  122.      * Stopped process status.  Returned
  123.      * only for traced children unless requested
  124.      * with the WUNTRACED option bit.
  125.      */
  126.     struct {
  127. #if BYTE_ORDER == LITTLE_ENDIAN 
  128.         unsigned int    w_Stopval:8,    /* == W_STOPPED if stopped */
  129.                 w_Stopsig:8,    /* signal that stopped us */
  130.                 w_Filler:16;    /* upper bits filler */
  131. #endif
  132. #if BYTE_ORDER == BIG_ENDIAN 
  133.         unsigned int    w_Filler:16,    /* upper bits filler */
  134.                 w_Stopsig:8,    /* signal that stopped us */
  135.                 w_Stopval:8;    /* == W_STOPPED if stopped */
  136. #endif
  137.     } w_S;
  138. };
  139. #define    w_termsig    w_T.w_Termsig
  140. #define w_coredump    w_T.w_Coredump
  141. #define w_retcode    w_T.w_Retcode
  142. #define w_stopval    w_S.w_Stopval
  143. #define w_stopsig    w_S.w_Stopsig
  144.  
  145. #define    WSTOPPED    _WSTOPPED
  146. #endif /* _POSIX_SOURCE */
  147.  
  148. #ifndef KERNEL
  149. #include <sys/types.h>
  150. #include <sys/cdefs.h>
  151.  
  152. __BEGIN_DECLS
  153. pid_t    wait __P((int *));
  154. pid_t    waitpid __P((pid_t, int *, int));
  155.  
  156. #ifndef _POSIX_SOURCE
  157. struct rusage;    /* forward declaration */
  158. pid_t    wait3 __P((int *, int, struct rusage *));
  159. pid_t    wait4 __P((pid_t, int *, int, struct rusage *));
  160. #endif /* !_POSIX_SOURCE */
  161. __END_DECLS
  162.  
  163. #endif /* !KERNEL */
  164.  
  165. #endif /* !_SYS_WAIT_H_ */
  166.